
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>HotSpot GC的触发条件？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>HotSpot GC的触发条件？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">新生代垃圾收集（Minor GC）最主要的触发条件是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当新生代的 Eden 区满时，会触发新生代垃圾收集。此时，所有活动的对象将会从 Eden 区转移到 Survivor 区，未活动的对象将被清除。</div>
          </div>
          <div class="card-source">来源: 1. 新生代垃圾收集（Minor GC）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">除了老年代自身空间占满，还有哪些常见情况会触发老年代垃圾收集（Full GC）？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">触发 Full GC 的其他常见情况包括：Minor GC后大量对象晋升导致老年代空间不足、通过 System.gc() 等API显式调用、以及JVM运行时因内存不足无法分配新对象时。</div>
          </div>
          <div class="card-source">来源: 2. 老年代垃圾收集（Major GC 或 Full GC）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">为什么不建议在生产环境中频繁调用 System.gc() 方法？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为通过 System.gc() 或 Runtime.gc() 等API显式调用垃圾收集器时，会触发 Full GC，这通常会带来较长的应用停顿，影响性能。这些方法主要用于测试和调试目的。</div>
          </div>
          <div class="card-source">来源: 2. 老年代垃圾收集（Major GC 或 Full GC）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">G1 (Garbage-First) 垃圾收集器的触发机制与其他收集器相比，有何独特之处？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">G1 垃圾收集器的独特之处在于，它会根据用户设置的回收目标（例如，目标停顿时间）来灵活地触发垃圾收集，而不仅仅是基于内存区域是否占满。</div>
          </div>
          <div class="card-source">来源: 3. 垃圾收集器特定的触发条件 > Garbage-First (G1)</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">CMS (Concurrent Mark-Sweep) 垃圾收集器通常在什么条件下触发老年代回收？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">CMS 主要在老年代的使用率达到一个预设的“高水位”时触发垃圾收集。此外，当新生代对象晋升到老年代且空间不足时，也会触发 Full GC。</div>
          </div>
          <div class="card-source">来源: 3. 垃圾收集器特定的触发条件 > Concurrent Mark-Sweep (CMS)</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">ZGC 和 Shenandoah GC 这类低延迟收集器的核心触发策略是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">ZGC 和 Shenandoah GC 的设计目标是实现低延迟，因此它们的核心触发策略是在内存压力变高时启动垃圾收集，以确保尽可能减少应用程序的停顿时间。</div>
          </div>
          <div class="card-source">来源: 3. 垃圾收集器特定的触发条件 > ZGC 和 Shenandoah GC</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">描述一种在 Minor GC 之后可能立即触发 Full GC 的具体场景。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当新生代的垃圾收集（Minor GC）完成后，如果有大量存活对象需要晋升（Promote）到老年代，而此时老年代的剩余空间不足以容纳这些对象，就会立即触发一次 Full GC。</div>
          </div>
          <div class="card-source">来源: 2. 老年代垃圾收集（Major GC 或 Full GC）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">对于 Serial GC 和 Parallel GC，它们触发新生代回收（Minor GC）的条件是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在使用 Serial GC 或 Parallel GC 时，新生代的垃圾收集（Minor GC）会在 Eden 区满时被触发。</div>
          </div>
          <div class="card-source">来源: 3. 垃圾收集器特定的触发条件 > Serial GC 和 Parallel GC</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">新生代中的 Survivor 区空间满了会发生什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">如果 Survivor 区（S0 或 S1）也满了，会触发 Minor GC，在此过程中，部分对象会被晋升到老年代，或者被移动到另一个空的 Survivor 区。</div>
          </div>
          <div class="card-source">来源: 1. 新生代垃圾收集（Minor GC）</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
